*Paper: Fiscal Rules, Corruption and Electoral Accountability - Replication Files

clear all
cap log close 
set more off


**Global files
global folder "/Users/tommasogiommoni/Dropbox/Determinants of corruption/Stability pact and corruption/Replication files JOP"


********************************************************************************
****----						Dataset open 					    	----**** 
********************************************************************************

use "$folder/Data/dataset_feb2024.dta", clear

**-- Global

global controls7 proportion_female_Elected_lag av_education_Elected_lag av_age_Elected_lag  victory_margin_lag term_limit_lag 
global controls7_int  c.proportion_female_Elected_lag##i.anno c.av_education_Elected_lag##i.anno c.av_age_Elected_lag##i.anno c.victory_margin_lag##i.anno  c.term_limit_lag##i.anno

**-- Panel dataset

xtset codcom anno
fvset base 2012 anno

********************************************************************************
****----				Analysis: Event-study (first column)			----**** 
********************************************************************************

quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<3000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg1
quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<2500 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg2
quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<2000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg3

coefplot (reg1, base offset(0) color(black) ciopts(recast(rcap) color(black black) lwidth(*0.75 *1.25)) label("BW: 3,000")) (reg2, offset(0.1) color(midblue) ciopts(recast(rcap) color(midblue midblue) lwidth(*0.75 *1.25)) label("BW: 2,500")) (reg3, offset(0.2) label("BW: 2,000")), vertical omitted keep(1.S#*.anno*)  yline(0) xline(9, lcolor(gray) lpattern(dash)) xlabel(1 "2004" 2 "2005" 3 "2006" 4 "2007" 5 "2008" 6 "2009" 7 "2010" 8 "2011" 9 "2012" 10 "2013" 11 "2014",  angle(45)) ///
ms(m) color(eltblue) ciopts(recast(rcap) color(eltblue eltblue) lwidth(*0.75 *1.25)) ylabel(-.4(0.1).4, angle(horizotal))  graphregion(color(white)) msize(small) levels(95 90) ytitle("") title("") legend(rows(1))
gr export "$folder/Figures/Figure3_a.png" , replace 

quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<3000 & FURs==1 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg1
quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<2500 & FURs==1 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg2
quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<2000 & FURs==1 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg3

coefplot (reg1, base offset(0) color(black) ciopts(recast(rcap) color(black black) lwidth(*0.75 *1.25)) label("BW: 3,000")) (reg2, offset(0.1) color(midblue) ciopts(recast(rcap) color(midblue midblue) lwidth(*0.75 *1.25)) label("BW: 2,500")) (reg3, offset(0.2) label("BW: 2,000")), vertical omitted keep(1.S#*.anno*)  yline(0) xline(9, lcolor(gray) lpattern(dash)) xlabel(1 "2004" 2 "2005" 3 "2006" 4 "2007" 5 "2008" 6 "2009" 7 "2010" 8 "2011" 9 "2012" 10 "2013" 11 "2014",  angle(45)) ///
ms(m) color(eltblue) ciopts(recast(rcap) color(eltblue eltblue) lwidth(*0.75 *1.25)) ylabel(-.7(0.1).7, angle(horizotal))  graphregion(color(white)) msize(small) levels(95 90) ytitle("") title("") legend(rows(1))
gr export "$folder/Figures/Figure3_c.png" , replace 

quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<3000 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg1
quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<2500 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg2
quietly xtreg corruption_PC_sd S##anno P i.region_year $controls7_int if abs(P)<2000 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg3

coefplot (reg1, base offset(0) color(black) ciopts(recast(rcap) color(black black) lwidth(*0.75 *1.25)) label("BW: 3,000")) (reg2, offset(0.1) color(midblue) ciopts(recast(rcap) color(midblue midblue) lwidth(*0.75 *1.25)) label("BW: 2,500")) (reg3, offset(0.2) label("BW: 2,000")), vertical omitted keep(1.S#*.anno*)  yline(0) xline(9, lcolor(gray) lpattern(dash)) xlabel(1 "2004" 2 "2005" 3 "2006" 4 "2007" 5 "2008" 6 "2009" 7 "2010" 8 "2011" 9 "2012" 10 "2013" 11 "2014",  angle(45)) ///
ms(m) color(eltblue) ciopts(recast(rcap) color(eltblue eltblue) lwidth(*0.75 *1.25)) ylabel(-.4(0.1).4, angle(horizotal))  graphregion(color(white)) msize(small) levels(95 90) ytitle("") title("") legend(rows(1))
gr export "$folder/Figures/Figure3_e.png" , replace 


********************************************************************************
****----					Analysis: DID (second column) 				----**** 
********************************************************************************

****---- Estimates 

**FCRs/FUCs
foreach i in 0 1 {
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1000 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1000_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1200 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1200_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1400 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1400_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1600 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1600_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1800 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1800_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2000 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2000_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2200 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2200_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2400 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2400_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2600 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2600_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2800 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2800_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3000 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3000_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3200 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3200_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3400 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3400_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3600 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3600_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3800 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3800_`i'_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<4000 & FURs==`i' & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_4000_`i'_z_int.dta", replace)
}

**All regions
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1000 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1000_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1200 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1200_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1400 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1400_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1600 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1600_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<1800 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1800_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2000 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2000_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2200 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2200_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2400 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2400_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2600 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2600_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<2800 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2800_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3000 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3000_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3200 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3200_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3400 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3400_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3600 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3600_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<3800 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3800_All_z_int.dta", replace)
quietly reghdfe corruption_PC_sd S##T P i.region_year $controls7_int if abs(P)<4000 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_4000_All_z_int.dta", replace)

****---- Figures

**FCRs
preserve
use "$folder/Data/estimates/est_1000_0_z_int.dta", clear
append using "$folder/Data/estimates/est_1200_0_z_int.dta"
append using "$folder/Data/estimates/est_1400_0_z_int.dta"
append using "$folder/Data/estimates/est_1600_0_z_int.dta"
append using "$folder/Data/estimates/est_1800_0_z_int.dta"
append using "$folder/Data/estimates/est_2000_0_z_int.dta"
append using "$folder/Data/estimates/est_2200_0_z_int.dta"
append using "$folder/Data/estimates/est_2400_0_z_int.dta"
append using "$folder/Data/estimates/est_2600_0_z_int.dta"
append using "$folder/Data/estimates/est_2800_0_z_int.dta"
append using "$folder/Data/estimates/est_3000_0_z_int.dta"
append using "$folder/Data/estimates/est_3200_0_z_int.dta"
append using "$folder/Data/estimates/est_3400_0_z_int.dta"
append using "$folder/Data/estimates/est_3600_0_z_int.dta"
append using "$folder/Data/estimates/est_3800_0_z_int.dta"
append using "$folder/Data/estimates/est_4000_0_z_int.dta"

qui keep if parm=="1.S#1.T"
qui gen sign=stderr*1.654
qui gen min90=estimate-sign
qui gen max90=estimate+sign
qui keep estimate min95 max95 min90 max90

qui gen h=.
qui replace h=1000 if _n==1
qui replace h=1200 if _n==2
qui replace h=1400 if _n==3
qui replace h=1600 if _n==4
qui replace h=1800 if _n==5
qui replace h=2000 if _n==6
qui replace h=2200 if _n==7
qui replace h=2400 if _n==8
qui replace h=2600 if _n==9
qui replace h=2800 if _n==10
qui replace h=3000 if _n==11
qui replace h=3200 if _n==12
qui replace h=3400 if _n==13
qui replace h=3600 if _n==14
qui replace h=3800 if _n==15
qui replace h=4000 if _n==16

twoway rcap min95 max95 h, color(black black) lwidth(*0.75) ||rcap min90 max90 h, color(black black) lwidth(*1.25) || connected estimate h, graphregion(color(white)) lpattern(dash) lcolor(grey) mcolor(black) ///
ylabel(-.4(0.1).4, angle(horizontal)) xlabel(1000(200)4000,  angle(45)) legend(off) title("") xtitle("Bandwidth") yline(0)
gr export "$folder/Figures/Figure3_b.png" , replace 
restore

**FURs
preserve
use "$folder/Data/estimates/est_1000_1_z_int.dta", clear
append using "$folder/Data/estimates/est_1200_1_z_int.dta"
append using "$folder/Data/estimates/est_1400_1_z_int.dta"
append using "$folder/Data/estimates/est_1600_1_z_int.dta"
append using "$folder/Data/estimates/est_1800_1_z_int.dta"
append using "$folder/Data/estimates/est_2000_1_z_int.dta"
append using "$folder/Data/estimates/est_2200_1_z_int.dta"
append using "$folder/Data/estimates/est_2400_1_z_int.dta"
append using "$folder/Data/estimates/est_2600_1_z_int.dta"
append using "$folder/Data/estimates/est_2800_1_z_int.dta"
append using "$folder/Data/estimates/est_3000_1_z_int.dta"
append using "$folder/Data/estimates/est_3200_1_z_int.dta"
append using "$folder/Data/estimates/est_3400_1_z_int.dta"
append using "$folder/Data/estimates/est_3600_1_z_int.dta"
append using "$folder/Data/estimates/est_3800_1_z_int.dta"
append using "$folder/Data/estimates/est_4000_1_z_int.dta"

qui keep if parm=="1.S#1.T"
qui gen sign=stderr*1.654
qui gen min90=estimate-sign
qui gen max90=estimate+sign
qui keep estimate min95 max95 min90 max90

qui gen h=.
qui replace h=1000 if _n==1
qui replace h=1200 if _n==2
qui replace h=1400 if _n==3
qui replace h=1600 if _n==4
qui replace h=1800 if _n==5
qui replace h=2000 if _n==6
qui replace h=2200 if _n==7
qui replace h=2400 if _n==8
qui replace h=2600 if _n==9
qui replace h=2800 if _n==10
qui replace h=3000 if _n==11
qui replace h=3200 if _n==12
qui replace h=3400 if _n==13
qui replace h=3600 if _n==14
qui replace h=3800 if _n==15
qui replace h=4000 if _n==16

twoway rcap min95 max95 h, color(black black) lwidth(*0.75) ||rcap min90 max90 h, color(black black) lwidth(*1.25) || connected estimate h, graphregion(color(white)) lpattern(dash) lcolor(grey) mcolor(black) ///
ylabel(-.6(0.1).6, angle(horizontal)) xlabel(1000(200)4000,  angle(45)) legend(off) title("") xtitle("Bandwidth") yline(0)
gr export "$folder/Figures/Figure3_d.png" , replace 
restore

**All regions
preserve
use "$folder/Data/estimates/est_1000_All_z_int.dta", clear
append using "$folder/Data/estimates/est_1200_All_z_int.dta"
append using "$folder/Data/estimates/est_1400_All_z_int.dta"
append using "$folder/Data/estimates/est_1600_All_z_int.dta"
append using "$folder/Data/estimates/est_1800_All_z_int.dta"
append using "$folder/Data/estimates/est_2000_All_z_int.dta"
append using "$folder/Data/estimates/est_2200_All_z_int.dta"
append using "$folder/Data/estimates/est_2400_All_z_int.dta"
append using "$folder/Data/estimates/est_2600_All_z_int.dta"
append using "$folder/Data/estimates/est_2800_All_z_int.dta"
append using "$folder/Data/estimates/est_3000_All_z_int.dta"
append using "$folder/Data/estimates/est_3200_All_z_int.dta"
append using "$folder/Data/estimates/est_3400_All_z_int.dta"
append using "$folder/Data/estimates/est_3600_All_z_int.dta"
append using "$folder/Data/estimates/est_3800_All_z_int.dta"
append using "$folder/Data/estimates/est_4000_All_z_int.dta"

qui keep if parm=="1.S#1.T"
qui gen sign=stderr*1.654
qui gen min90=estimate-sign
qui gen max90=estimate+sign
qui keep estimate min95 max95 min90 max90

qui gen h=.
qui replace h=1000 if _n==1
qui replace h=1200 if _n==2
qui replace h=1400 if _n==3
qui replace h=1600 if _n==4
qui replace h=1800 if _n==5
qui replace h=2000 if _n==6
qui replace h=2200 if _n==7
qui replace h=2400 if _n==8
qui replace h=2600 if _n==9
qui replace h=2800 if _n==10
qui replace h=3000 if _n==11
qui replace h=3200 if _n==12
qui replace h=3400 if _n==13
qui replace h=3600 if _n==14
qui replace h=3800 if _n==15
qui replace h=4000 if _n==16

twoway rcap min95 max95 h, color(black black) lwidth(*0.75) ||rcap min90 max90 h, color(black black) lwidth(*1.25) || connected estimate h, graphregion(color(white)) lpattern(dash) lcolor(grey) mcolor(black) ///
ylabel(-.4(0.1).4, angle(horizontal)) xlabel(1000(200)4000,  angle(45)) legend(off) title("") xtitle("Bandwidth") yline(0)
gr export "$folder/Figures/Figure3_f.png" , replace 
restore
